import 'package:finance_app/src/entities/contact_person_entity.dart';

contactPersonEntityFromJson(ContactPersonEntity data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['contact_id'] != null) {
		data.contactId = json['contact_id'] is String
				? int.tryParse(json['contact_id'])
				: json['contact_id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['country_code'] != null) {
		data.countryCode = json['country_code'].toString();
	}
	if (json['phone_number'] != null) {
		data.phoneNumber = json['phone_number'].toString();
	}
	if (json['email'] != null) {
		data.email = json['email'].toString();
	}
	if (json['position'] != null) {
		data.position = json['position'].toString();
	}
	if (json['is_primary'] != null) {
		data.isPrimary = json['is_primary'] is String
				? int.tryParse(json['is_primary'])
				: json['is_primary'].toInt();
	}
	if (json['created_by'] != null) {
		data.createdBy = json['created_by'];
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	return data;
}

Map<String, dynamic> contactPersonEntityToJson(ContactPersonEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['company_id'] = entity.companyId;
	data['contact_id'] = entity.contactId;
	data['name'] = entity.name;
	data['country_code'] = entity.countryCode;
	data['phone_number'] = entity.phoneNumber;
	data['email'] = entity.email;
	data['position'] = entity.position;
	data['is_primary'] = entity.isPrimary;
	data['created_by'] = entity.createdBy;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	return data;
}